package system_design.home.jiekou;

import system_design.home.shiti.Goods;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LENOVO
 * Date: 2022-01-06
 * Time: 16:43
 */
public class GoodsList {//存放商品的顺序表
    private Goods[] goods = new Goods[10];//商品数组
    private int UsedSize;//商品有效个数
    public GoodsList(){//构造方法  先默认三件商品
        goods[0] = new Goods(01,"泡面",3.5,5000);
        goods[1] = new Goods(02,"辣条",6,3000);
        this.UsedSize = 2;
    }

    public Goods getGoods(int pos) {//获取pos位置上的商品
        return this.goods[pos];
    }

    public void setGoods(int pos,Goods goods) {//设置pos下标为一件商品  添加一件商品 也就是get set方法
        this.goods[pos] = goods;
    }

    public int getUsedSize() {//得到当前有效元素个数
        return UsedSize;
    }

    public void setUsedSize(int usedSize) {//修改当前元素个数
        UsedSize = usedSize;
    }
}
